import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import '@/assets/styles/index.scss'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { useCommonStore } from '@/stores/common'

// 创建Vue应用
const app = createApp(App)

// 注册ElementPlus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 创建并使用Pinia状态管理
const pinia = createPinia()
app.use(pinia)

// 使用ElementPlus
app.use(ElementPlus)

// 使用路由
app.use(router)

// 应用启动前初始化通用数据
const commonStore = useCommonStore()
commonStore.initCommonData().then(() => {
  // 挂载应用
  app.mount('#app')
}) 